﻿
Public Class cImprimeFac
    Private lDsImpfac As dsImprimeFac
    Private Sub CalculaTotales()
        If lDsImpfac.ENCAFACIMPRIME.Rows.Count > 0 Then
            Dim drEnc As dsImprimeFac.ENCAFACIMPRIMERow = lDsImpfac.ENCAFACIMPRIME.Rows(0)
            Dim iIva As cTipoIva
            For Each drDet As dsImprimeFac.DETFACIMPRIMERow In lDsImpfac.DETFACIMPRIME.Rows
                iIva = New cTipoIva(drDet.IDIVA)
                If iIva.PorIva <> 0 Then
                    drEnc("VRGRAVADO") += cGeneral.NZ(drDet("VALORBASE")) * (drDet.DESCUENTO1 - 1) * (drDet.DESCUENTO2 - 1) * drDet.CANTIDAD
                    drEnc("IVA") += cGeneral.NZ(drDet("VALORIVA")) * (drDet.DESCUENTO1 - 1) * (drDet.DESCUENTO2 - 1) * drDet.CANTIDAD
                Else
                    drEnc("VRNOGRAVADO") += cGeneral.NZ(drDet("VALORBASE")) * (drDet.DESCUENTO1 - 1) * (drDet.DESCUENTO2 - 1) * drDet.CANTIDAD
                End If
            Next
        End If
    End Sub
    Public Sub New(ByVal TipoDoc As String, ByVal Numero As Integer)
        Try
            Dim daEnca As New dsImprimeFacTableAdapters.ENCAFACIMPRIMETableAdapter
            Dim daDeta As New dsImprimeFacTableAdapters.DETFACIMPRIMETableAdapter
            Dim daDescDe As New dsImprimeFacTableAdapters.DESCRIPCIONDETIMPRIMETableAdapter
            lDsImpfac = New dsImprimeFac
            daEnca.FillIdDocNumero(lDsImpfac.ENCAFACIMPRIME, TipoDoc, Numero)
            daDeta.FillIdDocNumero(lDsImpfac.DETFACIMPRIME, TipoDoc, Numero)
            daDescDe.FillIdDocNumero(lDsImpfac.DESCRIPCIONDETIMPRIME, TipoDoc, Numero)
            CalculaTotales()
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public ReadOnly Property DatosImprimeFac() As dsImprimeFac
        Get
            Return lDsImpfac
        End Get
    End Property
End Class
